package com.fy56.platform.logistics.common;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ToStringSerializer;
import com.fy56.platform.logistics.model.User;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by li on 2018-01-29.
 */
public abstract class AbstractModel implements Serializable {

    private static final long serialVersionUID = 1L;

    public static final String SPLIT = "⊙";
    public static final Integer YES = Integer.valueOf(1);
    public static final Integer No = Integer.valueOf(0);

    /**
     * 主键
     */
    @JSONField(serializeUsing= ToStringSerializer.class)
    protected Long id;

    /**
     * 创建者
     */
    protected User createBy;

    /**
     * 创建时间
     */
    protected Date createTime;

    /**
     *更新者
     */
    protected User updateBy;

    /**
     * 更新时间
     */
    protected Date updateTime;

    /**
     *删除标记（0：正常；1：删除；）
     */
    protected int deleteFlag;

    /**
     * 备注
     */
    protected String remark;

    /**
     * 插入数据前的初始化方法
     */
    public void initInsert(User createUser){
        this.setCreateBy(createUser);
        this.setCreateTime(new Date());
        this.setDeleteFlag(0);
    }

    /**
     * 更新数据前的初始化方法
     */
    public void initUpdate(User updateUser){
        this.setUpdateBy(updateUser);
        this.setUpdateTime(new Date());
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public int getDeleteFlag() {
        return deleteFlag;
    }

    public void setDeleteFlag(int deleteFlag) {
        this.deleteFlag = deleteFlag;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public User getCreateBy() {
        return createBy;
    }

    public void setCreateBy(User createBy) {
        this.createBy = createBy;
    }

    public User getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(User updateBy) {
        this.updateBy = updateBy;
    }
}
